package com.mywebsite.core.shared;

public class RegExp {
	public static native int checkPasswordLev(String pass)/*-{
		var letter = new RegExp("[a-z]|[A-Z]");
		var number = new RegExp("[0-9]");
		var isLetter = letter.test(pass);
		var isNumber = number.test(pass);
		
		if(pass.length<8||pass.length>20||(new RegExp("[^_]").test(pass)&&!isLetter&&!isNumber)){
			return -1;
		}
		if(new RegExp("[_]").test(pass)){
			return 3;
		}else if(isLetter && isNumber){
			return 2;
		}else{
			return 1;
		}
	}-*/;
	
	public static native boolean checkPhoneNumber(String phone)/*-{
		return new RegExp("^1[^0]{1}[0-9]{9}$","gi").test(phone);
	}-*/;
	
	public static native boolean checkCode(String code)/*-{
		return new RegExp("^[0-9]{4}$","gi").test(code);
	}-*/;
    public static  native boolean checkEmailNum(String emailNum)/*-{
	    return new RegExp("[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+\\.(([a-zA-Z0-9_-]{2,3}){1,2})$","gi").test(emailNum);
    }-*/;
    public static native boolean isNumber(String number)/*-{
		return new RegExp("[0-9]").test(number);
	}-*/;
}
